﻿Imports System.Data
Imports ADOEntityKYC
Imports System.Xml
Imports ADOEntity


Partial Class KYC_AMLList
    Inherits System.Web.UI.Page

#Region " Variable Gobal "
    Dim ds As DataSet
    Dim clsAMLList As clsAMLList = New clsAMLList
    Dim TranType As String
    Dim uniqueID1 As String
    Dim hdfUniqueID As String
    Dim UniqueType As String
    Dim PrefixTH As String
    Dim NameTh1 As String
    Dim NameTh2 As String
    Dim NameTh3 As String
    Dim PrefixEN As String
    Dim NameEn1 As String
    Dim NameEn2 As String
    Dim NameEn3 As String
    Dim Nationality As String
    Dim Occupation1 As String
    Dim OccOther1 As String
    Dim Business1 As String
    Dim BizOther1 As String
    Dim Des1 As String
    Dim Occupation2 As String
    Dim OccOther2 As String
    Dim Business2 As String
    Dim BizOther2 As String
    Dim Des2 As String
    Dim Occupation3 As String
    Dim OccOther3 As String
    Dim Business3 As String
    Dim BizOther3 As String
    Dim Des3 As String
    Dim IncomeSource1 As String
    Dim IncomeSource2 As String
    Dim IncomeSource3 As String
    Dim clsCheckLanguage As clsCheckLanguage
    Dim ListEntity As ListEntities = New ListEntities
    Dim clsDataTable As New clsLINQToDataTable
    Dim clsCheckID As clsCheckID
    Dim convertDate As clsDateFormat
    'Dim TypeKYC As String
    'Dim CustSeq As String


#End Region

    Protected Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load
        Try
            ds = Session("ds")
            clsAMLList = Session("clsAMLList")

            If Not IsPostBack Then
                QueryString()
                If Session("chkKYC") = Nothing Then
                    If checkBeforeCompile() = False Then
                        Session("chkKYC") = False
                        ScriptManager.RegisterStartupScript(UpdatePanel1, UpdatePanel1.GetType(), "clientScript", "window.close();", True)
                    Else
                        Session("chkKYC") = True
                        AutoInput()
                        CreateControlMP()
                        QuerySanction() 'สิ่งที่ต้องแก้เป็น web service

                        If ds.Tables("Result").Rows.Count = 0 Then
                            lblMsg.Visible = True
                            rdoSanction.Visible = False
                            btnOK.Enabled = True
                        Else
                            rdoSanction.Visible = True
                            grdList.Enabled = False
                        End If

                    End If
                Else
                    ScriptManager.RegisterStartupScript(UpdatePanel1, UpdatePanel1.GetType(), "clientScript", "window.close();", True)
                End If


            End If
        Catch ex As Exception
            ScriptManager.RegisterStartupScript(UpdatePanel1, _
                                                            UpdatePanel1.GetType(), _
                                                            "clientScript", _
                                                            "alert('" + ex.Message.Replace("'", "") + "')", _
                                                            True)


        End Try
    End Sub

    Protected Sub Page_Unload(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Unload
        Session("ds") = ds
    End Sub


#Region "SetForm"

    Sub CreateControlMP()
        Dim page As Label = CType(Master.FindControl("lblPage"), Label)
        page.Text = "ตรวจสอบ List"
    End Sub

#End Region

#Region "Function"

    Private Sub QueryString()
        Try

            hdfUniqueID = Request.QueryString("hdfUniqueID").Trim
            uniqueID1 = Request.QueryString("uniqueID").Trim
            TranType = Request.QueryString("TranType").Trim
            UniqueType = Request.QueryString("UniqueType").Trim
            PrefixTH = Request.QueryString("PrefixTH").Trim
            NameTh1 = Request.QueryString("NameTh1").Trim
            NameTh2 = Request.QueryString("NameTh2").Trim
            NameTh3 = Request.QueryString("NameTh3").Trim
            PrefixEN = Request.QueryString("PrefixEN").Trim
            NameEn1 = Request.QueryString("NameEn1").Trim
            NameEn2 = Request.QueryString("NameEn2").Trim
            NameEn3 = Request.QueryString("NameEn3").Trim
            Nationality = Request.QueryString("Nationality").Trim
            Occupation1 = Request.QueryString("Occupation1").Trim
            OccOther1 = Request.QueryString("OccOther1").Trim
            Business1 = Request.QueryString("Business1").Trim
            BizOther1 = Request.QueryString("BizOther1").Trim
            Des1 = Request.QueryString("Des1").Trim
            Occupation2 = Request.QueryString("Occupation2").Trim
            OccOther2 = Request.QueryString("OccOther2").Trim
            Business2 = Request.QueryString("Business2").Trim
            BizOther2 = Request.QueryString("BizOther2").Trim
            Des2 = Request.QueryString("Des2").Trim
            Occupation3 = Request.QueryString("Occupation3").Trim
            OccOther3 = Request.QueryString("OccOther3").Trim
            Business3 = Request.QueryString("Business3").Trim
            BizOther3 = Request.QueryString("BizOther3").Trim
            Des3 = Request.QueryString("Des3").Trim
            IncomeSource1 = Request.QueryString("IncomeSource1").Trim
            IncomeSource2 = Request.QueryString("IncomeSource2").Trim
            IncomeSource3 = Request.QueryString("IncomeSource3").Trim
            'TypeKYC = Request.QueryString("TypeKYC").Trim
            'CustSeq = Request.QueryString("CustSeq").Trim
        Catch ex As Exception
            Throw ex
        End Try
    End Sub

    Private Function checkBeforeCompile() As Boolean
        Try
            clsCheckID = New clsCheckID
            clsCheckLanguage = New clsCheckLanguage

            Dim result As Boolean = True

            If TranType = "" Then
                result = False
                GoTo chkresult
            End If

            If UniqueType = "1" Then

                If Not uniqueID1.Trim.Length = 13 Then
                    result = False
                    GoTo chkresult
                Else
                    If Not uniqueID1 = hdfUniqueID Then
                        If clsCheckID.checkUniqueID1(uniqueID1, Session("TypeKYCBoard"), Session("CustSeq")) = False Then
                            result = False
                            clsCheckID = Nothing
                            GoTo chkresult
                        ElseIf Not (clsCheckID.chkIDcard(uniqueID1.Trim)) Then
                            result = False
                            GoTo chkresult
                        End If
                    End If

                End If
            Else
                If uniqueID1.Trim.Length = 0 Then
                    result = False
                    GoTo chkresult
                End If
            End If

            If Nationality = "202" Then
                If PrefixTH = "" Or NameTh1 = "" Or NameTh3 = "" Then
                    result = False
                    GoTo chkresult
                ElseIf Not PrefixTH = "" And Not NameTh1 = "" And Not NameTh3 = "" Then
                    If clsCheckLanguage.checkLanguageTH(NameTh1, NameTh2, NameTh3) = False Then
                        result = False
                        GoTo chkresult
                    End If
                    'Else
                    '    If PrefixTH = "" Then
                    '        result = False
                    '        GoTo chkresult
                    '    End If

                    '    If NameTh1 = "" Then
                    '        result = False
                    '        GoTo chkresult
                    '    End If

                    '    If NameTh3 = "" Then
                    '        result = False
                    '        GoTo chkresult
                    '    End If
                End If
            End If


TH:
            If PrefixEN = "" Or NameEn1 = "" Or NameEn3 = "" Then
                result = False
                GoTo chkresult
            ElseIf Not PrefixEN = "" And Not NameEn1 = "" And Not NameEn3 = "" Then
                If clsCheckLanguage.checkLanguageEN(NameEn1, NameEn2, NameEn3) = False Then
                    result = False
                    GoTo chkresult
                End If
                'Else
                '    If PrefixEN = "" Then
                '        result = False
                '        GoTo chkresult
                '    End If

                '    If NameEn1 = "" Then
                '        result = False
                '        GoTo chkresult
                '    End If

                '    If NameEn3 = "" Then
                '        result = False
                '        GoTo chkresult
                '    End If
            End If

EN:
            If Nationality = "" Then
                result = False
                GoTo chkresult
            End If

            If Occupation1 = "" Then
                result = False
                GoTo chkresult
            Else
                If Not Occupation1 = "" Then
                    If Occupation1 = 98 Then 'เจ้าของ
                        If Business1 = "0" Then
                            result = False
                            GoTo chkresult
                        ElseIf Business1 = 99 Then
                            If BizOther1 = "" Then
                                result = False
                                GoTo chkresult
                            End If
                        End If
                    ElseIf Occupation1 = 99 Then 'อื่นๆ
                        If OccOther1 = "" Then
                            result = False
                            GoTo chkresult
                        End If
                    End If
                End If

                If Not Occupation2 = "" Then
                    If Occupation2 = 98 Then 'เจ้าของ
                        If Business2 = "0" Then
                            result = False
                            GoTo chkresult
                        ElseIf Business2 = 99 Then
                            If BizOther2 = "" Then
                                result = False
                                GoTo chkresult
                            End If
                        End If
                    ElseIf Occupation2 = 99 Then 'อื่นๆ
                        If OccOther2 = "" Then
                            result = False
                            GoTo chkresult
                        End If
                    End If
                End If

                If Not Occupation3 = "" Then
                    If Occupation3 = 98 Then 'เจ้าของ
                        If Business3 = "0" Then
                            result = False
                            GoTo chkresult
                        ElseIf Business3 = 99 Then
                            If BizOther3 = "" Then
                                result = False
                                GoTo chkresult
                            End If
                        End If
                    ElseIf Occupation3 = 99 Then 'อื่นๆ
                        If OccOther3 = "" Then
                            result = False
                            GoTo chkresult
                        End If
                    End If
                End If
            End If


            If IncomeSource1 = "" Then
                result = False
                GoTo chkresult
            End If

            clsCheckLanguage = Nothing

chkresult:
            Return result
        Catch ex As Exception
            WriteError(ex, "checkBeforeCompile")
            Throw ex

        End Try
    End Function

    Private Sub AutoInput()
        Try
            lblUniqueID.Text = uniqueID1
            lblTHName.Text = NameTh1 + "&nbsp;&nbsp;&nbsp;" + NameTh2 + "&nbsp;&nbsp;&nbsp;" + NameTh3
            lblENName.Text = (NameEn1.ToUpper + "&nbsp;&nbsp;&nbsp;" + NameEn2.ToUpper + "&nbsp;&nbsp;&nbsp;" + NameEn3.ToUpper)
        Catch ex As Exception
            Throw ex
        End Try
    End Sub


    Private Sub QuerySanction()

        'ถึงอ้ำ
        'แก้โค๊ดส่วนี้ ให้ไปเรียก web service โดยผลลัพธ์ที่ได้ให้ใส่ใน dataset ชื่อเดิมที่ทำไว้ 
        'โดยให้ส่งค่าไป web service 4 รอบ คือ ชื่อ-สกุล, สกลุ-ชื่อ ทั้งภาษาไทย อังกฤษ
        'แล้วให้รวมผลลัพธ์ไว้ที่ dataset ตัวเดียวกัน แล้วโชว์ผลลัพธ์ที่ grid
        'ชื่อที่ส่งไปให้ตัดอักขระพิเศษก่อน ให้ไปก๊อปปี้ที่หน้า NonIndividualSearc ที่ฟังชันก์ cutSpecialCharacter
        '
        'แก้ที่ saveData ในหน้านี้ด้วย เป็นการบันทึกผลลัพธ์ ให้แก้ฟิวด์ที่บอกว่าทำชั่วคราว เป็นฟิวด์ที่บอกให้พี่หนุ่ยส่งว่างๆ กลับมา ทำเพื่อเป็นการบันทึกว่ามีการเลือกรายการไหนไว้บ้าง
        'หน้าจอ AMLList กับ AMLListBiz แก้เหมือนกัน ต่างกันที่ type ที่แยกระหว่างบุคคลกะนิติ



        Try
            ''Dim THName As String = NameTh1.Trim.Substring(0, NameTh1.Trim.Length / 2).Trim
            ''Dim ENName As String = NameEn1.Trim.Substring(0, NameEn1.Trim.Length / 2).ToUpper.Trim

            'Dim qryList = From A In ListEntity.MAMLLIST _
            '                Where A.AMLTYPE = 1 And A.ISACTIVE = True
            '                Select A

            'If Not NameTh1.Trim = "" Then
            '    qryList = qryList.Where(Function(c) c.FIRSTNAME.Contains(NameTh1.Trim) Or c.LASTNAME.Contains(NameTh3.Trim) Or c.FULLNAME.Contains(NameTh1.Trim))
            'Else
            '    qryList = qryList.Where(Function(c) c.FIRSTNAME.ToUpper.Contains(NameEn1.Trim.ToUpper) Or c.LASTNAME.ToUpper.Contains(NameEn3.Trim.ToUpper) Or c.FULLNAME.ToUpper.Contains(NameEn1.Trim.ToUpper))
            'End If

            'If Not NameTh1.Trim = "" And Not NameEn1.Trim = "" Then
            '    qryList = qryList.Where(Function(c) c.FIRSTNAME.Contains(NameTh1.Trim) Or c.LASTNAME.Contains(NameTh3.Trim) Or c.FULLNAME.Contains(NameTh1.Trim) Or c.FIRSTNAME.ToUpper.Contains(NameEn1.Trim.ToUpper) Or c.LASTNAME.ToUpper.Contains(NameEn3.Trim.ToUpper) Or c.FULLNAME.ToUpper.Contains(NameEn1.Trim.ToUpper))
            'ElseIf Not NameTh1.Trim = "" Then
            '    qryList = qryList.Where(Function(c) c.FIRSTNAME.Contains(NameTh1.Trim) Or c.LASTNAME.Contains(NameTh3.Trim) Or c.FULLNAME.Contains(NameTh1.Trim))
            'ElseIf Not NameEn1.Trim = "" Then
            '    qryList = qryList.Where(Function(c) c.FIRSTNAME.ToUpper.Contains(NameEn1.Trim.ToUpper) Or c.LASTNAME.ToUpper.Contains(NameEn3.Trim.ToUpper) Or c.FULLNAME.ToUpper.Contains(NameEn1.Trim.ToUpper))
            'End If


            'If (ds.Tables.Contains("dsList")) Then
            '    ds.Tables.Remove("dsList")
            'End If

            'ds.Tables.Add(clsDataTable.LINQToDataTable(qryList, "dsList").Copy)
            callWSVToChkName(NameTh1.Trim, NameTh2.Trim, NameTh3.Trim, _
                             NameEn1.Trim, NameEn2.Trim, NameEn3.Trim)



            'qryList = Nothing
        Catch ex As Exception
            Throw ex
        End Try
    End Sub

    Private Function cutSpecialCharacter(ByVal bizName As String) As String
        Try
            Dim nameSearch As String = ""
            nameSearch = bizName.Trim.Replace(" ", "").Replace("&", "").Replace("'", "").Replace("(", "").Replace(")", "").Replace(",", "").Replace("-", "").Replace(".", "").Replace("""", "")

            Return nameSearch
        Catch ex As Exception
            Throw ex
        End Try
    End Function


    Private Sub callWSVToChkName(ByVal strFirstNameTh As String, ByVal strMidNameth As String, ByVal strLastNameTh As String, _
                                 ByVal strFirstNameEn As String, ByVal strMidNameEn As String, ByVal strLastNameEn As String)

        Dim SanctionEntity As New SanctionEntities
        Dim clsLINQToDataTable As New clsLINQToDataTable
        Dim intCountRowTh As Integer = 0
        Dim intCountRowEn As Integer = 0
        Dim intCountRowUniqueID As Integer = 0
        Dim total As Integer = 0
        Dim icount As Integer = 0
        Dim drItem As DataRow()
        Dim dsService As New DataSet

        Try
            If (ds.Tables.Contains("Result")) Then
                ds.Tables.Remove("Result")
            End If


            ' เป็นการดึง service เช็คชื่อภาษาไทย------------------------------------------------------------------------
            Dim objCallDataTH As New wsvSearchTh.ProcDQsvrsvc_th
            Dim objPrmNameTH As New wsvSearchTh.Parameters
            With objPrmNameTH
                .firstName = cutSpecialCharacter(strFirstNameTh)
                .middleName = cutSpecialCharacter(strMidNameth)
                .lastName = cutSpecialCharacter(strLastNameTh)
            End With

            Dim doc As XmlDocument = New XmlDocument

            doc.LoadXml(objCallDataTH.procDQsvrsvc_th(objPrmNameTH))
            dsService.ReadXml(New XmlNodeReader(doc))

            drItem = Nothing
            drItem = dsService.Tables("Result").Select("FirstName=''")
            icount = drItem.Length
            For i = 0 To icount - 1
                drItem(i).Delete()
            Next
            dsService.Tables("Result").AcceptChanges()

            intCountRowTh = dsService.Tables("Result").Rows.Count

            '--------------------------------------------------------------------------------------------------

            ' เป็นการดึง service เช็คชื่อภาษาอังกฤษ------------------------------------------------------------------------
            Dim objCallDataEN As New wsvSearchEn.ProcDQsvrsvc_en
            Dim objPrmNameEN As New wsvSearchEn.Parameters
            With objPrmNameEN
                .firstName = strFirstNameEn.ToUpper
                .middleName = strMidNameEn.ToUpper
                .lastName = strLastNameEn.ToUpper
            End With
            doc = New XmlDocument
            doc.LoadXml(objCallDataEN.procDQsvrsvc_en(objPrmNameEN))
            dsService.ReadXml(New XmlNodeReader(doc))

            drItem = Nothing
            drItem = dsService.Tables("Result").Select("FirstName=''")
            icount = drItem.Length
            For i = 0 To icount - 1
                drItem(i).Delete()
            Next
            dsService.Tables("Result").AcceptChanges()

            intCountRowEn = dsService.Tables("Result").Rows.Count - intCountRowTh


            '-----------------------------9---------------------------------------------------------------------
            'ทำการคิวรี ด้วย uniqueID

            Dim tblSaction = From tblAmlList In SanctionEntity.AMLLIST_THAI Where tblAmlList.UNIQUEID = uniqueID1 _
                             Select tblAmlList.UNIQUEID, tblAmlList.FIRSTNAME, tblAmlList.MIDDLENAME, _
                             tblAmlList.LASTNAME, tblAmlList.CUSTTYPE, FULLNAME = tblAmlList.FIRSTNAME & " " & tblAmlList.LASTNAME, tblAmlList.COUNTRY, tblAmlList.DATASOURCE, tblAmlList.RISKLEVEL, _
                             tblAmlList.LASTUPDATEDATE, SELECTLIST = "", tblAmlList.COMMENT1, tblAmlList.COMMENT2

            'dsService.Tables.Add(clsLINQToDataTable.LINQToDataTable(tblSaction, "Result"))
            'dsService.Tables("Result").Merge(clsLINQToDataTable.LINQToDataTable(tblSaction, "Result"))

            Dim dtSanction As DataTable = Nothing
            dtSanction = clsLINQToDataTable.LINQToDataTable(tblSaction, "Result")
            'Try
            For iCountDtTable = 0 To dtSanction.Rows.Count - 1
                dsService.Tables("Result").ImportRow(clsLINQToDataTable.LINQToDataTable(tblSaction, "Result")(iCountDtTable))
            Next
            'Catch ex As Exception

            'End Try

            intCountRowUniqueID = dsService.Tables("Result").Rows.Count - (intCountRowTh + intCountRowEn)
            total = intCountRowTh + intCountRowEn + intCountRowUniqueID


            ds.Tables.Add(dsService.Tables("result").Copy)

            grdList.DataSource = ds.Tables("Result")
            grdList.DataBind()

            For iCountBegin As Integer = 0 To total - 1
                If (iCountBegin >= 0 And iCountBegin < intCountRowTh) Then
                    Dim arrColor() As Integer = {152, 251, 152}
                    'setGridRowBackground(grdList, iCountBegin, Drawing.Color.Honeydew)
                    setGridRowBackground(grdList, iCountBegin, arrColor)
                End If
                If (iCountBegin >= intCountRowTh And iCountBegin < (intCountRowTh + intCountRowEn)) Then
                    Dim arrColor() As Integer = {255, 222, 173}
                    'setGridRowBackground(grdList, iCountBegin, Drawing.Color.PapayaWhip)
                    setGridRowBackground(grdList, iCountBegin, arrColor)
                End If
                If (iCountBegin >= (intCountRowTh + intCountRowEn) And iCountBegin < (intCountRowTh + intCountRowEn + intCountRowUniqueID)) Then
                    Dim arrColor() As Integer = {255, 187, 255}
                    'setGridRowBackground(grdList, iCountBegin, Drawing.Color.LavenderBlush)
                    setGridRowBackground(grdList, iCountBegin, arrColor)
                End If
            Next

        Catch ex As Exception
            WriteError(ex, "callWSVToChkName")
            Throw ex
        End Try
    End Sub

    Private Sub setGridRowBackground(ByVal Grid As GridView, ByVal intRow As Integer, ByVal colorBack As Drawing.Color)
        Try
            Grid.Rows(intRow).BackColor = colorBack
            'Grid.Rows(intRow).BackColor.FromArgb(,,)
        Catch ex As Exception
            WriteError(ex, "setGridRowBackground")
            Throw ex
        End Try
    End Sub

    Private Sub setGridRowBackground(ByVal Grid As GridView, ByVal intRow As Integer, ByVal colorBack As Array)
        Try
            'Grid.Rows(intRow).BackColor = colorBack
            Grid.Rows(intRow).BackColor = Drawing.Color.FromArgb(colorBack(0), colorBack(1), colorBack(2))
        Catch ex As Exception
            WriteError(ex, "setGridRowBackground")
            Throw ex
        End Try
    End Sub

    Private Function checkBeforeSave() As Boolean
        Try
            Dim result As Boolean = False
            If rdoSanction.SelectedIndex = 0 Then
                Dim chk As CheckBox
                For i As Integer = 0 To grdList.Rows.Count - 1
                    chk = CType(grdList.Rows(i).FindControl("chkList"), CheckBox)
                    If chk.Checked = True Then
                        result = True
                    End If
                Next
            Else
                result = True
            End If

            Return result
        Catch ex As Exception
            WriteError(ex, "checkBeforeSave")
            Throw ex
        End Try
    End Function

    Private Sub saveData()
        Try
            Dim chk As CheckBox
            For i As Integer = 0 To grdList.Rows.Count - 1
                chk = CType(grdList.Rows(i).FindControl("chkList"), CheckBox)
                If chk.Checked = True Then
                    ds.Tables("Result").Rows(i)("SELECTLIST") = "0" 'ทำชั่วคราว รอเปลี่ยนฟิลด์อีกที
                    If grdList.Rows(i).Cells(3).Text = "PEPs" Then
                        If Session("Sanction") = Nothing Then
                            Session("Sanction") = "- พบรายชื่อใน PEPs List"
                        Else
                            Session("Sanction") += ", " + "PEPs"
                        End If
                    Else
                        If Session("Sanction") = Nothing Then
                            Session("Sanction") = "- พบรายชื่อใน " + grdList.Rows(i).Cells(3).Text
                        Else
                            Session("Sanction") += ", " + grdList.Rows(i).Cells(3).Text
                        End If
                    End If
                Else
                    ds.Tables("Result").Rows(i)("SELECTLIST") = "1" 'ทำชั่วคราว รอเปลี่ยนฟิลด์อีกที

                End If
                ds.Tables("Result").AcceptChanges()
            Next

        Catch ex As Exception
            WriteError(ex, "saveData")
            Throw ex
        End Try
    End Sub

#End Region

#Region "Event Button"

    Protected Sub btnOK_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles btnOK.Click
        Try
            If checkBeforeSave() = True Then
                saveData()
                'ScriptManager.RegisterStartupScript(UpdatePanel1, UpdatePanel1.GetType(), "clientScript", "window.close();", True)

                Dim ret As String = "3" 'ค่าที่ต้องการ return 
                ScriptManager.RegisterStartupScript(UpdatePanel1, UpdatePanel1.GetType(), "SendValueBack", "window.returnValue = '" + ret + "';self.close();", True)


            Else
                ScriptManager.RegisterStartupScript(btnOK, Page.GetType(), "alert", "alert('กรุณาเลือกรายชื่อในลิสต์')", True)
            End If
        Catch ex As Exception
            ScriptManager.RegisterStartupScript(UpdatePanel1, _
                                                            UpdatePanel1.GetType(), _
                                                            "clientScript", _
                                                            "alert('" + ex.Message.Replace("'", "") + "')", _
                                                            True)
        End Try
    End Sub

#End Region

    Protected Sub rdoSanction_SelectedIndexChanged(ByVal sender As Object, ByVal e As System.EventArgs) Handles rdoSanction.SelectedIndexChanged
        If rdoSanction.SelectedIndex = 0 Then
            btnOK.Enabled = True
            grdList.Enabled = True
        Else
            btnOK.Enabled = True
            grdList.Enabled = False
        End If

    End Sub

    Protected Sub grdList_RowDataBound(ByVal sender As Object, ByVal e As System.Web.UI.WebControls.GridViewRowEventArgs) Handles grdList.RowDataBound
        If (e.Row.RowType.ToString = "DataRow") Then
            Dim lblActiveDate As Label = CType(e.Row.FindControl("lblActiveDate"), Label)
            If Not (lblActiveDate.Text = "") Then
                convertDate = New clsDateFormat
                lblActiveDate.Text = convertDate.chkDateThOrEn(clsDateFormat.enmDateCultureInfo.Th, lblActiveDate.Text)
                convertDate = Nothing
            End If
            e.Row.Attributes.Add("onmouseover", "javascript:this.style.cursor = 'pointer';")
            e.Row.Attributes.Add("ondblclick", "win = window.showModalDialog('frmshowDetail.aspx?RowIndexDetail=" & e.Row.RowIndex & "',null,'width=600,height=800','_blank');")
        End If
    End Sub

    Public Sub WriteError(ByVal objEx As Exception, ByVal strFunctionName As String)
        Try

       
        Dim clsSessionMenuRight As clsSessionMenuRight = Session("clsMenuRight")
        Dim cls As New clsWriteError
        cls.GetstrErrorMessage = objEx.Message
        cls.GetstrErrorException = If(objEx.InnerException Is Nothing, "", objEx.InnerException.Message)
        cls.GetstrFromName = "AMLList"
        cls.GetstrUserName = clsSessionMenuRight.getUserName
        cls.GetstrUserRight = clsSessionMenuRight.getUserRight
        cls.GetstrFunctionName = strFunctionName
        cls.CreateFileXml(clsSessionMenuRight.getBranchCode)
        clsSessionMenuRight = Nothing
            cls = Nothing
        Catch ex As Exception

        End Try
    End Sub


End Class
